package pilgun.eshop;

import java.util.List;


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import pilgun.eshop.domain.Cart;
import pilgun.eshop.domain.Item;
import pilgun.eshop.domain.Order;
import pilgun.eshop.domain.User;
import pilgun.eshop.repository.ItemRepository;
import pilgun.eshop.repository.OrderRepository;

public class App{
    public static void main( String[] args ){
    	ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{ "repositoryContext.xml"});
    	ItemRepository itemRepository = context.getBean("itemRepository", ItemRepository.class);
    	OrderRepository orderRepository = context.getBean("orderRepository", OrderRepository.class);
    	List<Item> itemList = itemRepository.getItemList();
    	for (Item i : itemList){
    		System.out.println(i);
    	}
    	Order order = orderRepository.getOrderById(1);
    	System.out.println(order);
    	User user1 = new User();
    	Cart cart1 = new Cart();
    	User user2 = new User();
    	Cart cart2 = new Cart();
    	user1.setId(1);
    	user2.setId(2);
    	Item item= new Item();
    	item.setId(1);
    	cart1.addToItemList(item);
    	cart2.addToItemList(item);
    	orderRepository.confirmOrder(cart1, user1);
    	orderRepository.confirmOrder(cart2, user2);
    	
    }
}
